#(c)2009 DVN tyson.malchow@gmail.com

project (dvn)
cmake_minimum_required(VERSION 2.6)

#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_MODULE_PATH
	${CMAKE_SOURCE_DIR}/cmake/Modules
)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
	message(STATUS "Debug mode enabled.")
	add_definitions(-DDEBUG)
else()
	message(STATUS "Release mode enabled.")
endif()

# Disallow in-source build
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" dvn_in_source)
if(dvn_in_source)
	message(FATAL_ERROR "DVN requires an out of source build. Please create a separate build directory and run 'cmake path_to_source [options]' there.")
endif()

# check for unix environment
if(NOT UNIX)
	message(FATAL_ERROR "DVN requires a UNIX-like environment.")
endif()

# set up build parameters
set(VERSION_MAJOR 0)
set(VERSION_MINOR 9)
set(VERSION_BUILD 47)
set(PACKAGE_STRING "DVN ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}")
set(RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)

# get general includes
include(CheckIncludeFile)
include(CheckFunctionExists)
include(CheckLibraryExists)

# run system-wide tests
include (TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)

# config header....
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

# compile options
add_definitions(-Wall --std=c99 -D__USE_BSD -D_SVID_SOURCE)
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )

# recurse!
add_subdirectory(src/shared)
add_subdirectory(src/core)
#add_subdirectory(src/client)
#add_subdirectory(src/test)

